package cn.iocoder.yudao.module.erp.dal.mysql.stock;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * ERP 库存盘点单项 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ErpStockCheckItemMapper extends BaseMapperX<ErpStockCheckItemDO> {

    default List<ErpStockCheckItemDO> selectListByCheckId(Long checkId) {
        return selectList(ErpStockCheckItemDO::getCheckId, checkId);
    }

    default List<ErpStockCheckItemDO> selectListByCheckIds(Collection<Long> checkIds) {
        return selectList(ErpStockCheckItemDO::getCheckId, checkIds);
    }

    default int deleteByCheckId(Long checkId) {
        return delete(ErpStockCheckItemDO::getCheckId, checkId);
    }

//    @Insert("<script> " +
//            "INSERT INTO erp_stock_check_item (id,check_id,dept_id,add_del_type,product_id,product_unit_id,product_batch,product_validity_date,count,stock_count,actual_count,remark,creator,create_time) " +
//            "<foreach collection='items' item='item' separator=','> " +
//            "(#{item.id}, #{item.name}, #{item.quantity}, #{item.checkDate})" +
//            "</foreach> " +
//            "</script>")
//    void insertStockCheckItem(@NotEmpty(message = "出库项列表不能为空") @Valid List<ErpStockCheckSaveReqVO.Item> items);
}